package domain;

import utils.CommandAnalyzer;
import enums.Gender;
import basic.Date;
import basic.CRUDable;

//@author A0098891H
public class FamilyMember extends CRUDable{
	//attributes 
	
	private String _name;
	private Gender _gender;

	private Date _birthDate;
	private String _description;
 
	/**
	 * 
	 */
	public FamilyMember()
	{
		this._name = "";
		this._gender = Gender.NOT_DEFINED;
		this._birthDate = new Date();
		this._description = "no description";
	}
	/**
	 * @param name
	 */
	public FamilyMember(String name)
	{
		this._name = name;
		this._gender = Gender.NOT_DEFINED;
		this._birthDate = new Date();
		this._description = "no description";
	}
	
	/**
	 * @param member
	 */
	public FamilyMember(FamilyMember member)
	{
		this.set(member);
	}
	/**
	 * 
	 * @param member
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set(FamilyMember member)
	{
		this._name = member._name;
		this.set_gender(member._gender);
		this.set_birthDate(member._birthDate);
		this.set_description(member._description);
	}
	
	/**
	 *
	 * @see java.lang.Object#toString()
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public String toString()
	{
		return this._name;
	}
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public String writeToString()
	{
		return this._name + "," + _id
				+ "," + CommandAnalyzer.PARAM_GENDER + _gender
				+ "," + CommandAnalyzer.PARAM_BIRTHDATE + _birthDate
				+ "," + CommandAnalyzer.PARAM_COMMENTS + _description;
	}
	
	//getters and setters
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public String get_name() {
		return _name;
	}

	/**
	 * 
	 * @param name
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set_name(String name) {
		this._name = name;
	}
	
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public Gender get_gender() {
		return _gender;
	}

	/**
	 * 
	 * @param gender
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set_gender(Gender gender) {
		if(gender!=CommandAnalyzer.NA_GENDER)
			this._gender = gender;
	}
	
	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public Date get_birthDate() {
		return _birthDate;
	}
	
	/**
	 * 
	 * @param birthDate
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set_birthDate(Date birthDate) {
		if(!birthDate.toString().equals(Date.NA_DATE))
			this._birthDate = birthDate;
	}

//	public String get_firstName() {
//		return _firstName;
//	}
//
//	public void set_firstName(String firstName) {
//		this._firstName = firstName;
//	}
//
//	public String get_familyName() {
//		return _familyName;
//	}
//
//	public void set_familyName(String familyName) {
//		this._familyName = familyName;
//	}
//
//	public String get_middleName() {
//		return _middleName;
//	}
//
//	public void set_middleName(String middleName) {
//		this._middleName = middleName;
//	}

	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public String get_description() {
		return _description;
	}

	/**
	 * 
	 * @param description
	 * @Precondition 
	 * @Postcondition 
	 */
	public void set_description(String description) {
		if(!description.equals(CommandAnalyzer.NA_COMMENTS))
			this._description = description;
	}
	
	/**
	 * 
	 * @param member
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public boolean isSame(FamilyMember member)
	{
		if(this._name.equalsIgnoreCase(member._name))
		{
			return true;
		}
		return false;
	}

}
